package com.android.superobstacleavoider;

public class BoundingSphere {

	private Vector3 m_center = new Vector3();
	private float m_radius;

	public Vector3 getCenter() {
		return m_center;
	}

	public void setCenter(Vector3 a_center) {
		m_center = a_center;
	}

	public float getRadius() {
		return m_radius;
	}

	public void setRadius(float a_radius) {
		m_radius = a_radius;
	}

	public BoundingSphere(Vector3 a_center, float a_radius) {
		m_center.set(a_center);
		m_radius = a_radius;
	}

	public boolean sphereIntersects(BoundingSphere a_other) {
		float distance = m_center.distSquared(a_other.getCenter());
		float radiusSum = m_radius + a_other.getRadius();
		return distance <= radiusSum * radiusSum;
	}

	public boolean pointIntersects(Vector3 a_point) {
		return m_center.distSquared(a_point) < m_radius * m_radius;
	}
}
